﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Category.aspx.cs" Inherits="Admin_Category" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Main_HeaderContentPlaceHolder" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Main_MainContentPlaceHolder" runat="Server">
    <div id="maincontainer">
        <div id="topsection">
            <div class="innertube">
                <asp:Label ID="Label1" runat="server" SkinID="Lable100"  Text="عنوان گروه:"></asp:Label>
                <asp:TextBox ID="CategoryTitleTextBox" runat="server" SkinID="TextBox200"></asp:TextBox>
                <asp:Label ID="Label2" runat="server" SkinID="Lable100" Text="اندازه صفحه:"></asp:Label>
                <asp:DropDownList ID="PageSizeDropDownList" runat="server" SkinID="DropDownList198">
                    <asp:ListItem Selected="True" Value="5">[پیش فرض]</asp:ListItem>
                    <asp:ListItem Value="5">5 رکورد</asp:ListItem>
                    <asp:ListItem Value="10">10 رکورد</asp:ListItem>
                    <asp:ListItem Value="15">15 رکورد</asp:ListItem>
                    <asp:ListItem Value="20">20 رکورد</asp:ListItem>
                    <asp:ListItem Value="25">25 رکورد</asp:ListItem>
                    <asp:ListItem Value="1000000">تمام رکورد ها</asp:ListItem>
                </asp:DropDownList>
                <asp:ImageButton ID="SearchImageButton" runat="server" OnClick="SearchImageButton_Click"
                    SkinID="SearchButton" />
                <asp:ImageButton ID="ClearImageButton" runat="server" OnClick="ClearImageButton_Click"
                    OnClientClick="return false;" SkinID="ClearButton" />
            </div>
        </div>
        <div id="contentwrapper">
            <div id="contentcolumn">
                <div class="innertube">
                    <asp:GridView ID="CategoryGridView" runat="server" AutoGenerateColumns="False" DataKeyNames="CategoryID"
                        DataSourceID="CategoryEntityDataSource" HorizontalAlign="Center" OnSelectedIndexChanged="CategoryGridView_SelectedIndexChanged"
                        PageSize="5" Width="300px" AllowSorting="True" >
                        <Columns>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:ImageButton ID="SelectImageButton" runat="server" CommandName="Select" SkinID="SelectButton" />
                                </ItemTemplate>
                                <ItemStyle Width="25px" />
                            </asp:TemplateField>
                            <asp:BoundField DataField="CategoryID" Visible="False" />
                            <asp:BoundField DataField="CategoryTitle" HeaderText="عنوان گروه آزمایش" SortExpression="CategoryTitle">
                                <ItemStyle HorizontalAlign="Right" VerticalAlign="Middle" />
                            </asp:BoundField>
                        </Columns>
                    </asp:GridView>
                </div>
            </div>
        </div>
        <div id="leftcolumn">
            <div class="innertube">
                <asp:FormView ID="CategoryFormView" runat="server" DataSourceID="CategoryEntityDataSource"
                    DataKeyNames="CategoryID" DefaultMode="Insert" OnItemDeleted="CategoryFormView_ItemDeleted"
                    OnItemCommand="CategoryFormView_ItemCommand" Width="350px">
                    <EditItemTemplate>
                        <table border="0" cellpadding="0" cellspacing="0" style="width: 350px;font-family:Tahoma">
                            <tr valign="middle">
                                <td style="width: 100px" align="right">
                                    عنوان:
                                </td>
                                <td style="width: 250px" align="right">
                                    <asp:TextBox Font-Names="B Yekan" ID="TitleTextBox" runat="server" Text='<%# Bind("CategoryTitle") %>'
                                        MaxLength="500" Width="230px" />
                                    <asp:RequiredFieldValidator ID="TitleRequiredFieldValidator" runat="server" ControlToValidate="TitleTextBox"
                                        Display="Dynamic" ErrorMessage="*" ValidationGroup="Update"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr valign="middle">
                                <td style="width: 100px" align="right">
                                    توضیحات:
                                </td>
                                <td>
                                  <asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>'
                                        TextMode="MultiLine" MaxLength="2500" Height="150px" Width="250px" />
                                </td>
                            </tr>                        
                            <tr>
                                <td colspan="2" align="left">
                                    <table border="0" cellpadding="0" cellspacing="0" style="width: 100%">                                       
                                        <tr>
                                            <td style="height: 15px">
                                                &nbsp;
                                            </td>
                                            <td align="left" valign="top" style="width: 65px">
                                                <asp:ImageButton ID="DeleteImageButton" runat="server" CausesValidation="False" CommandName="Delete"
                                                    SkinID="DeleteButton" OnClientClick="if (!confirm('آيا از حذف مطمئن هستيد؟')) return false;" />
                                            </td>
                                            <td align="left" valign="top" style="width: 65px">
                                                <asp:ImageButton ID="UpdateImageButton" runat="server" CommandName="Update" SkinID="UpdateButton"
                                                    ValidationGroup="Update" OnClientClick="if (!confirm('آيا از اعمال تغییرات مطمئن هستيد؟')) return false;" />
                                            </td>
                                            <td align="left" valign="top" style="width: 65px">
                                                <asp:ImageButton ID="CancelImageButton" runat="server" CommandName="Cancel" SkinID="CancelButton" />
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <table border="0" cellpadding="0" cellspacing="0" style="width: 350px;font-family:Tahoma">
                            <tr valign="middle">
                                <td style="width: 100px" align="right">
                                    عنوان:
                                </td>
                                <td style="width: 250px" align="right">
                                    <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("CategoryTitle") %>'
                                        MaxLength="500" Width="250px" />
                                    <asp:RequiredFieldValidator ID="TitleRequiredFieldValidator" runat="server" ControlToValidate="TitleTextBox"
                                        Display="Dynamic" ErrorMessage="*" ValidationGroup="Insert"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr valign="middle">
                                <td style="width: 100px;vertical-align:top;" align="right">
                                    توضیحات:
                                </td>
                                <td>
                                  <asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>'
                                        TextMode="MultiLine" MaxLength="2500" Height="150px" Width="250px" />
                                </td>
                            </tr>                          
                            <tr>
                                <td colspan="2" align="left">
                                    <table border="0" cellpadding="0" cellspacing="0" style="width: 100%">                                    
                                        <tr>
                                            <td style="height: 15px">
                                                &nbsp;
                                            </td>
                                            <td align="left" valign="top" style="width: 65px;">
                                                <asp:ImageButton ID="InsertButton" runat="server" CommandName="Insert" SkinID="InsertButton"
                                                    ValidationGroup="Insert" />
                                            </td>
                                            <td align="left" valign="top" style="width: 65px;">
                                                <asp:ImageButton ID="CancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                                                    SkinID="CancelButton" />
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </InsertItemTemplate>
                </asp:FormView>
            </div>
        </div>
        <div id="footer">
            <a href="http://www.anahita.com/">شرکت دلتا سیستم آناهیتا</a></div>
    </div>
    </div>
    <asp:EntityDataSource ID="CategoryEntityDataSource" runat="server" ConnectionString="name=DataEntities"
        DefaultContainerName="DataEntities" EntitySetName="Categories" Where="(@CategoryTitle is null || it.CategoryTitle LIKE '%' + @CategoryTitle + '%')"
        EnableUpdate="True" EnableDelete="True" EnableInsert="True" EnableFlattening="False"
        OnDeleted="CategoryEntityDataSource_Command" OnInserted="CategoryEntityDataSource_Command"
        OnUpdated="CategoryEntityDataSource_Command" AutoGenerateOrderByClause="True">
        <WhereParameters>
            <asp:ControlParameter ControlID="CategoryTitleTextBox" Name="CategoryTitle" Type="String" />
        </WhereParameters>
        <OrderByParameters>
            <asp:ControlParameter ControlID="CategoryGridView" Name="OrderBy" PropertyName="SortExpression"
                Type="String" />
        </OrderByParameters>
    </asp:EntityDataSource>
    <asp:HiddenField ID="CategoryIDHiddenField" runat="server" />
</asp:Content>
